package com.service.impl;

import com.dao.Export_infoDao;
import com.dao.impl.Export_infoDaoImpl;
import com.pojo.Export_info;
import com.service.Export_infoService;
import com.util.PageUtil;

import java.util.List;

public class Export_infoServiceImpl implements Export_infoService {

    Export_infoDao exportInfoDao = new Export_infoDaoImpl();

    /***
     * 获取每页出库列表、页码、页面大小、总数、总页数
     * @param pageIndex
     * @param pageSize
     * @param search
     * @return
     */
    @Override
    public PageUtil<Export_info> findPageExportList(int pageIndex, int pageSize, String search) {
        List<Export_info> pageExportList = exportInfoDao.findPageExportList(pageIndex, pageSize, search);
        int allExportCount = exportInfoDao.findAllExportCount(search);
        int pageCount = (int) Math.ceil((double) allExportCount / pageSize);
        PageUtil<Export_info> exportInfoPageUtil = new PageUtil<>(pageIndex, pageSize, allExportCount, pageCount, pageExportList);
        return exportInfoPageUtil;
    }

    /***
     * 获取单个出库信息、编辑页面
     * @param id
     * @return
     */
    @Override
    public Export_info findExportById(int id) {
        return exportInfoDao.findExportById(id);
    }

    /***
     * 编辑更新出库
     * @param exportInfo
     * @return
     */
    @Override
    public int updateExport(Export_info exportInfo) {
        return exportInfoDao.updateExport(exportInfo);
    }

    /***
     * 添加出库
     * @param exportInfo
     * @return
     */
    @Override
    public int addExport(Export_info exportInfo) {
        return exportInfoDao.addExport(exportInfo);
    }

    /***
     * 删除出库 status 0是有效 1是无效
     * @param id
     * @return
     */
    @Override
    public int delExport(int id) {
        return exportInfoDao.delExport(id);
    }

    /***
     * 公共方法设置出库对象的属性
     * @param ids
     * @return
     */
    @Override
    public int delExports(String ids) {
        return exportInfoDao.delExports(ids);
    }

    @Override
    public Integer queryExportQuantityByMedicineId(int id) {
        return exportInfoDao.queryExportQuantityByMedicineId(id);
    }
}
